package cn.school.entity;

import java.util.ArrayList;
import java.util.List;

public class Page<T> {
	private int pageNo = 1;
	private int totalLines;
	private int totalPage;
	private int pageSize;

	private List<T> datas = new ArrayList<>(0);

	public Page() {
	}

	public Page(int pageNo, int totalLines, int pageSize, List<T> datas) {
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		// this.totalLines = totalLines;
		this.setTotalLines(totalLines);

		this.datas = datas;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getTotalLines() {
		return totalLines;
	}

	public void setTotalLines(int totalLines) {
		this.totalLines = totalLines;
		this.totalPage = this.totalLines / this.pageSize + (this.totalLines % this.pageSize == 0 ? 0 : 1);
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public List<T> getDatas() {
		return datas;
	}

	public void setDatas(List<T> datas) {
		this.datas = datas;
	}

	@Override
	public String toString() {
		return "Page{" + "pageNo=" + pageNo + ", totalLines=" + totalLines + ", totalPage=" + totalPage + ", pageSize="
				+ pageSize + ", datas=" + datas + '}';
	}
}
